package org.dashboard.client.widget;

import com.google.gwt.dom.client.Node;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Random;
import com.google.gwt.user.client.ui.SimplePanel;

/**
 * @author Simon Vogensen, Lakeside
 * @version $Revision$
 */
public class ImageWidget extends SimplePanel {

    public void replaceImageNoCache(String url) {
        url = url + (url.contains("?")?"&":"?")+"randparam="+Random.nextInt(10000);
        replaceImage(url);
    }

    public void replaceImage(final String url) {
        Node node = ImageWidget.this.getElement().getChild(0).getChild(0);
        DOM.setStyleAttribute((Element) node, "backgroundImage", "url("+url+")");
    }
}
